﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CARMSData.EntityClasses;

namespace CARMS.Report
{
    [Function("Report.ReportSelect")]
    public partial class ReportSelect :PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                BindDefault();
            }
        }

        private void  BindDefault()
        {
            ControlHelper.BindReportList(dplReportList,EmptyType.PleaseSelect);
        }

        protected void btnContinueReport_Click(object sender,EventArgs e)
        {
            if(dplReportList.SelectedValue.Trim().Length>0)
            {
                var report = new ReportCategoryEntity(int.Parse(dplReportList.SelectedValue));
                if(!report.IsNew)
                {
                    if(report.CreationUrl.Trim().Length>0)
                    {
                        RediretResolveUrl(report.CreationUrl+"?ReportCategoryID="+report.ReportCategoryId);
                    }
                    else
                    {
                        Alert("Please set the report targe url address."); 
                    }
                }
            }else
            {
                Alert("Please select a report to create.");
            }
        }
    }
}
